//
//  BookOrderDetailFooterCell.m
//  KuWeiPark
//
//  Created by Kevin Su on 15/5/5.
//  Copyright (c) 2015年 Clief. All rights reserved.
//

#import "BookOrderDetailFooterCell.h"
#import "AppMacro.h"

@implementation BookOrderDetailFooterCell

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)awakeFromNib{
    
    self.cancelBtn.layer.masksToBounds = YES;
    self.cancelBtn.layer.cornerRadius = 5;
    
    self.payBtn.layer.masksToBounds = YES;
    self.payBtn.layer.cornerRadius = 5;
}

- (void)initDataWithBookingOrderModel:(BookingOrderDetailModel *)detailModel{
    
    self.bookResultLabel.text = [NSString stringWithFormat:@"预订车位数%i个合计订金%@元", detailModel.subBookingOrderList.count, detailModel.bookingOrderAmount];
    
    switch ([detailModel.bookingOrderStatus integerValue]) {
        case BOOKING_PAY_WAIT:
        {
            //未支付
            self.payBtn.enabled = YES;
            self.cancelBtn.enabled = YES;
            self.payBtn.backgroundColor = MAIN_GREEN_COLOR;
            self.cancelBtn.backgroundColor = RGBACOLOR(191, 191, 191, 1);
            self.subTipLabel.hidden = NO;
        }
        case BOOKING_CANCEL:{
            
            //已取消
            self.payBtn.enabled = NO;
            self.cancelBtn.enabled = NO;
            self.payBtn.backgroundColor = RGBACOLOR(191, 191, 191, 1);
            self.cancelBtn.backgroundColor = RGBACOLOR(191, 191, 191, 1);
            self.subTipLabel.hidden = YES;
            break;
        }
        case BOOKING_FAILURE:{
            
            break;
        }
        case BOOKING_SUCCESS:{
            
            //已支付
            self.payBtn.enabled = NO;
            self.cancelBtn.enabled = YES;
            self.payBtn.backgroundColor = RGBACOLOR(191, 191, 191, 1);
            self.cancelBtn.backgroundColor = MAIN_GREEN_COLOR;
            self.subTipLabel.hidden = NO;
        }
        case BOOKING_TIMEOUT:{
            
            break;
        }
        default:
            break;
    }

}

- (IBAction)cancelOrder:(id)sender {
    
    if(self.delegate && [self.delegate respondsToSelector:@selector(cancelOrderAction)]){
        
        [self.delegate cancelOrderAction];
    }
}

- (IBAction)payOrder:(id)sender {
    
    if(self.delegate && [self.delegate respondsToSelector:@selector(payOrderAction)]){
        
        [self.delegate payOrderAction];
    }
}


@end
